<?php
	require_once 'dmq/Database.php';
	$db = new dmq\Database();
			if($db->open())
			{echo "haha";}
			else {echo "neeej";}
			

	$playerId = null;
	if(isset($_COOKIE['userid']))
	{
		$playerId = $_COOKIE['userid'];	
	}
	if($playerId != null)
	{
		

			echo "Omg";
			$turnTimer = 0;
			$games = array();
			if($stmt = $db->Prepare("SELECT GameID FROM GameParticipants WHERE UserID = ?"))
			{		
				$stmt->bind_param("s", $playerId);
				$stmt->execute();
				$stmt->bind_result( $gameId );
				while($stmt->fetch())
				{
					$games[] = $gameId;
				}
				$stmt->close();
				$db->Close();
			}
			echo '{"gameId":'.json_encode($games).'}';
		
	}